package heven.holt.library.extensions

import android.app.Activity
import android.app.Application
import android.content.Context
import android.os.Bundle

val activityList: MutableList<Activity> = mutableListOf()

fun Application.registerActivityLifecycleCallback() {
    registerActivityLifecycleCallbacks(AppActivityLifecycleCallbacks())
}

class AppActivityLifecycleCallbacks : Application.ActivityLifecycleCallbacks {
    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
        activityList.add(activity)
    }

    override fun onActivityStarted(activity: Activity) {
    }

    override fun onActivityResumed(activity: Activity) {
    }

    override fun onActivityPaused(activity: Activity) {
    }

    override fun onActivityStopped(activity: Activity) {
    }

    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
    }

    override fun onActivityDestroyed(activity: Activity) {
        activityList.remove(activity)
    }
}